package uba.fi.tda.tp1.sorts;

public class ShellSort extends GenericSort{

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected int[] sortMethod(int[] numbers) {
		int lenght = numbers.length;
		
		for ( int incremento = lenght / 2;incremento > 0; incremento = (incremento == 2 ? 1 : (int) Math.round(incremento / 2.2))) {
			for (int i = incremento; i < lenght; i++) {
					for (int j = i; j >= incremento && numbers[j - incremento] > numbers[j]; j -= incremento) {
						int aux = numbers[j];
						numbers[j] = numbers[j - incremento];
						numbers[j - incremento] = aux;
					}
			}
		}
		
		return numbers;
	}
}
